<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card style="max-width: 600px">
          <template #header>
            <div class="card-header">
              <span>自动库设备上架模拟</span>
            </div>
          </template>
          <div id="up">
            <el-form :inline="true" :model="upSimulateParams" label-width="75">
              <el-form-item label="托盘条码">
                <el-input v-model="upSimulateParams.contNo" maxlength="6" show-word-limit placeholder="请输入托盘条码"
                  clearable></el-input>
              </el-form-item>
              <el-form-item label="货位编号">
                <el-input v-model="upSimulateParams.locationNo" maxlength="16" show-word-limit placeholder="请输入上架货位编号"
                  clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="up">模拟上架</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card style="max-width: 600px">
          <template #header>
            <div class="card-header">
              <span>产线站台模拟</span>
            </div>
          </template>
          <div id="arrive">
            <el-form :inline="true" :model="arriveSimulateParams" label-width="75">
              <el-form-item label="托盘条码">
                <el-input v-model="arriveSimulateParams.contNo" placeholder="请输入托盘条码" maxlength="6" show-word-limit
                  clearable></el-input>
              </el-form-item>
              <el-form-item label="站台编号">
                <el-input v-model="arriveSimulateParams.stationNo" placeholder="请输入到达站台编号" maxlength="16"
                  show-word-limit clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="arrive">模拟到达</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card style="max-width: 600px">
          <template #header>
            <div class="card-header">
              <span>自动库设备下架模拟</span>
            </div>
          </template>
          <div id="down">
            <el-form :inline="true" :model="downSimulateParams" label-width="75">
              <el-form-item label="托盘条码">
                <el-input v-model="downSimulateParams.contNo" placeholder="请输入托盘条码" maxlength="6" show-word-limit
                  clearable></el-input>
              </el-form-item>
              <el-form-item label="货位编号">
                <el-input v-model="downSimulateParams.locationNo" placeholder="请输入下架货位编号" maxlength="16" show-word-limit
                  clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="down">模拟下架</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card style="max-width: 600px">
          <template #header>
            <div class="card-header">
              <span>盘点移动模拟</span>
            </div>
          </template>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script setup name="Simulate">
import { ref } from "vue"
import { data } from "./index.js"
import { upSimulate, downSimulate, ArriveSimulate } from "@/api/wms/simulate"
import userUserStore from '@/store/modules/user'

const { proxy } = getCurrentInstance();
const userStore = userUserStore()
const upSimulateParams = ref(data.upSimulateParams)
const downSimulateParams = ref(data.downSimulateParams)
const arriveSimulateParams = ref(data.arriveSimulateParams)
const up = () => {
  upSimulateParams.value.creator = userStore.id;
  upSimulate(upSimulateParams.value).then((response) => {
    proxy.$modal.msgSuccess(response.msg);
  }).catch((error) => { });
  console.log("模拟上架,参数:", upSimulateParams)
}

const down = () => {
  downSimulateParams.value.creator = userStore.id;
  downSimulate(downSimulateParams.value).then((response) => {
    proxy.$modal.msgSuccess(response.msg);
  }).catch((error) => { });
  console.log("模拟下架,参数:", downSimulateParams)
}
const arrive = () => {
  arriveSimulateParams.value.creator = userStore.id;
  ArriveSimulate(arriveSimulateParams.value).then((response) => {
    proxy.$modal.msgSuccess(response.msg);
  }).catch((error) => { });
  console.log("模拟到达,参数:", arriveSimulateParams)
}
</script>
<style scoped>
.el-row {
  margin-bottom: 20px;
}
</style>
